<?php 
/*
 * Copyright (c) Taras Kudla, 2010
 */
/*
 * Kernel objects
 */
abstract class kernel {
	private static $system = null;
	protected $core = null;
	function __construct( init & $Gepard){
		if( !is_object(self::$system) || get_class(self::$system)!="init" ){
			self::$system = &$Gepard;
		}
		$this-> core = & self::$system;
	}
	public function init(){
		# initialization method code	
	}
	function __clone(){
		
	}
	public function void(){
		return null;
	}
}
/*
 * Module abstraction
 */
abstract class module {
	private static $system;	
	protected $api = null;
	protected $lang = null;
	protected $name = null;
	protected $langfilespath = null;
	function __construct(init & $Gepard){
		if( !is_object(self::$system) || get_class(self::$system)!="init" ){
			self::$system = &$Gepard;
		}
		$this-> api = & self::$system;	
		$env = $this->api->Getenvcaller();
		$module=$env["MOD"];
		$this->name = $env["MOD"];
		$this->api->lang->setModuleLanguage($module, $this->api->GetSysLanguages(), $this->api->GetLanguage(), $this->lang,$this->langfilespath);
	}
	public function init(){
		# module initialization code
	}
	
	public function defaultaction(){
		# default module action, see docs for more information
	}
	
	# returns url to module path
	public function getmyurl(){
		return $this->api->url()."mod/".$this->name."/";
	}
	# returns module files folder 
	public function getmypath(){
		return $this->api->path()."mod/".$this->name."/";
	}
	
	public function install(){
		# module installation code		
	}
	public function uninstall(){
		# module uninstalling code
	}
	function __clone(){
		
	}
	public function void(){
		#  
		return null;
	}}
/*
 * Library layer
 */
abstract class library {
	private static $system;	
	protected $api = null;
	protected $lang = null;
		
	function __construct(init & $Gepard){
		if( !is_object(self::$system) || get_class(self::$system)!="init" ){//if($this->SystemCalled==false){
			self::$system = &$Gepard;
	}
	$this-> api = & self::$system;	
	}
	public function init(){
		# library object initialization code
	}
}
/*
 * Interfaces
 */
 
# templates engines
interface tplengine{
	public function bindvar($varname,$varvalue);
	public function deletevar($varname);
	public function setvars( $vars );


}
 
# database objects interface
interface dbostruct
	{
		public function select($table,$fields="*",$sql=null);
		public function insert($table,array $data,$returnid=null);
		public function update($table,$sql);
		public function delete($table,$sql);
		public function execute($sql);
		public function connect($serv,$port,$db,$user,$passwd);
		public function disconnect();
		public function version();
		public function createtable(sqltable $map);
		public function droptable($table);
		public function tableexists($table);
		public function getfields($table);
		public function gettables($database=null);
		public function getdatabases();
		public function getdatabase();
	}
# caching engine interface
interface cachestruct
	{
		public function connect($server,$port);
		public function set($key,&$value);
		public function get($key);
		public function delete($key);
		public function disconnect();
		public function flush();
		public function stats();
	}
?>
